/*
 * Copyright 2013-2018 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.cqrcb.cloud.controller;


import com.cqrcb.cloud.config.annotation.CustomLogAnnotation;
import com.cqrcb.cloud.config.annotation.CustomValidation;
import com.cqrcb.cloud.entity.activity.io.ActivityIO;
import com.cqrcb.cloud.entity.api.req.Q;
import com.cqrcb.cloud.entity.api.res.R;
import com.cqrcb.cloud.entity.quota.io.MultiQuotaCtrlMarketMainIO;
import com.cqrcb.cloud.feign.MultiQuotaCtrlMarketMainServiceFeign;
import com.cqrcb.cloud.service.ActivityPerformService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @author yangxueyong
 */
@Slf4j
@Api("活动执行接口")
@RestController
public class TestController {

	@Autowired
	private ActivityPerformService activityPerformService;

	@Autowired
	private MultiQuotaCtrlMarketMainServiceFeign multiQuotaCtrlMarketMainServiceFeign;

	//执行
	@CustomLogAnnotation
	@PostMapping("/perform")
	@ApiOperation(value = "活动执行", notes = "活动执行")
//	@ApiImplicitParam(name = "活动入参", value = "活动入参", required = true, dataType = "ActivityIO")
	public R<?> perform(@RequestBody Q<ActivityIO> activityIOQ) {
        return activityPerformService.perform(activityIOQ);
	}

	@CustomValidation
	@CustomLogAnnotation
	@PostMapping("/deduction")
	@ApiOperation(value = "活动执行", notes = "活动执行")
	public R deduction(@RequestBody  Q<MultiQuotaCtrlMarketMainIO> multiQuotaCtrlMarketMainVoQ) {
		log.info("这是什么-->>>");
		R r = multiQuotaCtrlMarketMainServiceFeign.deduction2(multiQuotaCtrlMarketMainVoQ);
		return r;
	}

	@GetMapping("/ttt")
	public String ttt() {
		return "ttt";
	}

}
